import {request} from 'umi';
import type {BasicListItemDataType} from './data.d';
import {EmployeeListItem} from "@/pages/Employee/List/data";

type ParamsType = {
  count?: number;
} & Partial<BasicListItemDataType>;


export async function abList(params: {
  // query
  /** 当前的页码 */
  current?: number;
  /** 页面的容量 */
  pageSize?: number;
  /** 部门ID */
  orgId?: number;
}, code: any) {
  return request<{
    data: any;
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/v2/open/common/ab/list/' + code, {
    method: 'GET',
    params: {
      ...params,
      pageNum: params.current,
      // orderByColumn: "postSort",
      // isAsc: 'desc'
    },
  });
}

export async function queryFakeList(
  params: ParamsType,
): Promise<{ data: { list: BasicListItemDataType[] } }> {
  return request('/api/get_list', {
    params,
  });
}

export async function removeFakeList(
  params: ParamsType,
): Promise<{ data: { list: BasicListItemDataType[] } }> {
  return request('/api/post_fake_list', {
    method: 'POST',
    data: {
      ...params,
      method: 'delete',
    },
  });
}

export async function addFakeList(
  params: ParamsType,
): Promise<{ data: { list: BasicListItemDataType[] } }> {
  return request('/api/post_fake_list', {
    method: 'POST',
    data: {
      ...params,
      method: 'post',
    },
  });
}

export async function updateFakeList(
  params: ParamsType,
): Promise<{ data: { list: BasicListItemDataType[] } }> {
  return request('/api/post_fake_list', {
    method: 'POST',
    data: {
      ...params,
      method: 'update',
    },
  });
}
